//
//  XycjVC+UI.swift
//  Auscultation
//
//  Created by 来 on 2020/12/10.
//

import Foundation

extension XycjVC {
    
    func initUI() {
        
        let top_view = UIImageView.init(image: #imageLiteral(resourceName: "beijing2@1.5x"))
        top_view.isUserInteractionEnabled = true
        view.addSubview(top_view)
        top_view.snp.makeConstraints { (make) in
            make.top.left.right.equalToSuperview()
            make.height.equalTo(UIDevice.lgf_NavBarH() + 80)
        }
        self.navTitle = "心音采集"
        self.lgf_NavigationBar.lgf_Title?.textColor = UIColor.white
        self.lgf_NavigationBar.lgf_line?.isHidden = true
        
        let image_view2 = UIImageView.init(image: #imageLiteral(resourceName: "shebei@1.5x"))
        top_view.addSubview(image_view2)
        image_view2.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(20)
            make.width.height.equalTo(18)
            make.centerY.equalToSuperview().multipliedBy(1.6)
        }
        
        let label1 = UILabel.init()
        label1.text = "设备编号："
        label1.textColor = UIColor.white
        label1.font = UIFont.boldSystemFont(ofSize: 15)
        top_view.addSubview(label1)
        label1.snp.makeConstraints { (make) in
            make.left.equalTo(image_view2.snp.right).offset(5)
            make.centerY.equalTo(image_view2)
            make.width.equalTo(80)
        }
        
        sbbh = UILabel.init()
        sbbh.text = EWEBluetooth.lgf.selectPeripheral?.identifier.uuidString ?? "未知"
        sbbh.textColor = UIColor.white
        sbbh.lgf_AddShowAllText()
        sbbh.numberOfLines = 1
        sbbh.font = UIFont.boldSystemFont(ofSize: 15)
        top_view.addSubview(sbbh)
        sbbh.snp.makeConstraints { (make) in
            make.left.equalTo(label1.snp.right)
            make.centerY.equalTo(image_view2)
            make.width.equalTo(150)
        }
        
        onLine = UILabel.init()
        onLine.text = "在线"
        onLine.textColor = UIColor.green
        onLine.font = UIFont.boldSystemFont(ofSize: 15)
        top_view.addSubview(onLine)
        onLine.snp.makeConstraints { (make) in
            make.right.equalToSuperview().offset(-20)
            make.centerY.equalTo(image_view2)
        }
        
        onOff = UIView.init()
        onOff.backgroundColor = UIColor.green
        onOff.layer.cornerRadius = 5
        top_view.addSubview(onOff)
        onOff.snp.makeConstraints { (make) in
            make.width.height.equalTo(10)
            make.right.equalTo(onLine.snp.left).offset(-5)
            make.centerY.equalTo(image_view2)
        }
        
        line_view = EWELineView.init(frame: CGRect.init(x: 0, y: 0, w: UIDevice.lgf_ScreenW - 30, h: 200))
        line_view.backgroundColor = UIColor.white
        line_view.layer.borderWidth = 1.0
        line_view.layer.borderColor = UIColor.init(lgf_HexString: "f0f0f0")?.cgColor
        view.addSubview(line_view)
        line_view.snp.makeConstraints { (make) in
            make.top.equalTo(top_view.snp.bottom).offset(20)
            make.width.equalToSuperview().offset(-30)
            make.centerX.equalToSuperview()
            make.height.equalTo(200)
        }
        
        time = UILabel.init()
        time.text = "00:00"
        time.font = UIFont.boldSystemFont(ofSize: 40)
        time.textColor = UIColor.init(lgf_HexString: "222222")
        view.addSubview(time)
        time.snp.makeConstraints { (make) in
            make.top.equalTo(line_view.snp.bottom).offset(50)
            make.centerX.equalToSuperview()
        }
        
        caiji = UIButton.init(type: .custom)
        caiji.backgroundColor = UIColor.init(lgf_HexString: EWEDarkMode.c_0F88F2)!
        caiji.setTitle("开始采集", for: .normal)
        caiji.setTitleColor(EWEDarkMode.white(), for: .normal)
        caiji.titleLabel?.font = UIFont.systemFont(ofSize: 15)
        caiji.layer.cornerRadius = 4
        caiji.layer.masksToBounds = true
        caiji.addTarget(self, action: #selector(XycjVC.kscj(_:)), for: .touchUpInside)
        view.addSubview(caiji)
        caiji.snp.makeConstraints { (make) in
            make.top.equalTo(time.snp.bottom).offset(50)
            make.centerX.equalToSuperview()
            make.width.equalToSuperview().offset(-75)
            make.height.equalTo(44)
        }
        
    }

}
